package com.gis3c.sys.processor;

import com.gis3c.sys.dao.SystemDao;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;

/**
 * Created by Hukekuan on 2017/11/13 0013.
 */
@Component("instantiationTracingBeanPostProcessor")
public class InstantiationTracingBeanPostProcessor
        implements ApplicationListener<ContextRefreshedEvent> {
    @Value("#{configProperties['sys.initMessage']}")
    private String initMessage;
    @Resource private SystemDao systemDao;

    @Override
    public void onApplicationEvent(ContextRefreshedEvent event){
        if(event.getApplicationContext().getParent() == null){
            List<String> allTables = systemDao.queryAllTableNames();
            allTables.forEach(tableName ->{
                System.out.println(tableName);
            });
        }
    }
}
